<?php


namespace app\model;


use app\utils\DateTime;
use app\utils\PasswordConvert;

class RoomPassword extends BaseModel
{
    protected $updateTime = '';
    protected $createTime = '';

    public function setDateTime(){
        return new DateTime();
    }

    public function setPasswordConvert(){
        return new PasswordConvert();
    }

    public function setPasswordAttr($value){
        return $this->setPasswordConvert()->encryption($value);
    }

    public function getPasswordAttr($value){
        return $this->setPasswordConvert()->decrypt($value);
    }

    public function setStartTimeAttr($value){
        return $this->setDateTime()->setTime($value);
    }

    public function setEndTimeAttr($value){
        return $this->setDateTime()->setTime($value);
    }

    public function getStartTimeAttr($value){
        return $this->setDateTime()->getTime($value);
    }

    public function getEndTimeAttr($value){
        return $this->setDateTime()->getTime($value);
    }

    public function Room(){
        return $this->hasOne(Room::class , 'id' , 'room_id');
    }
}
